<?php 
    $url = new Url();
    /*echo "<pre>";
                print_r($assign_data);
                echo "</pre>";                */
?>
<div id="main" class="nosidebar">
    <!--<div id="sidebar">
    <h3>Vấn đề</h3>
    <a href="javascript:">Tất cả vấn đề</a><br>
    <a href="javascript:">Tóm tắt</a><br>        
    <a href="javascript:">Biểu đồ sự kiện</a><br>        
    </div>-->

    <div id="content">

        <div class="contextual">    
            <?php foreach($assign_data as $row){
                if($row['assign_user_id'] == $_SESSION['user_pm']['user_id']){                
                 ?>
            <a href="<?php echo $url->createUrl("task/logtime",array("task_id"=>$task_data['task_id'])); ?>" class="icon icon-time-add">Cập nhật</a>                          
            <?php } } ?>          
            <?php if($_SESSION['project_pm']['project_admin_id'] == $_SESSION['user_pm']['user_id']){ ?>
                <a href="<?php echo $url->createUrl("task/update",array("task_id"=>$task_data['task_id'])); ?>" class="icon icon-edit">Sửa</a>
                <a href="javascript:" class="icon icon-del" rel="nofollow" onclick="delete_task(<?php echo $task_data['task_id']; ?>)">Xóa</a>
                <?php } ?>
        </div>

        <h2>Công việc #<?php echo $task_data['task_id'] . " - " . $task_data['task_name']; ?></h2>

        <div class="issue status-3 priority-4 created-by-me details">

            <div class="subject">
                <div><h3><?php echo $task_data['task_name']; ?></h3></div>
            </div>
            <p class="author">
                thêm bởi <a href="<?php echo $url->createUrl("user/detail",array("user_id"=>$task_data['task_create_user'])); ?>"><?php echo $task_data['fullname']; ?></a> vào lúc <a href="javascript:" title="14-09-2012 06:56"><?php echo date('H:i d/m/Y',$task_data['task_create_date']); ?></a>.
            </p>

            <table class="attributes">
                <tbody>
                    <tr>
                        <th class="status">Trạng thái:</th>
                        <td class="status"><?php switch($task_data['task_status']){ case 1:echo "Mới";break;case 2:echo "Đang thực hiện";break;case 3:echo "Đã hoàn thành";break; } ?></td>
                        <th class="start-date">Bắt đầu:</th>
                        <td class="start-date"><?php echo date('d/m/Y',$task_data['task_start_date']); ?></td>
                    </tr>
                    <tr>
                        <th class="priority">Ưu tiên:</th>
                        <td class="priority"><?php switch($task_data['task_priority']){ case 1:echo "Thấp";break;case 2:echo "Bình thường";break;case 3:echo "Cao";break; } ?></td>
                        <th class="due-date">Hết hạn:</th>
                        <td class="due-date"><?php echo date('d/m/Y',$task_data['task_end_date']); ?></td>
                    </tr>
                    <tr>
                        <th class="assigned-to">Gán cho:</th>
                        <td class="assigned-to">
                            <?php for($i=0;$i<count($assign_data);$i++){ ?>
                                <a href="<?php echo $url->createUrl("user/detail",array("user_id"=>$assign_data[$i]['assign_user_id'])); ?>"><?php echo $assign_data[$i]['fullname']; ?></a>                                                                
                                <?php if($i != (count($assign_data)-1)){ echo "<br>";} } ?>                            
                        </td>
                        <th class="progress">Tiến độ:</th>
                        <td class="progress">
                            <table class="progress" style="width: 80px;">
                                <tbody>
                                    <tr>
                                        <?php if($task_data['task_percent_done'] != 0){ ?>
                                            <td class="closed" style="width: <?php echo $task_data['task_percent_done']; ?>%;"></td>
                                            <?php } ?>                                        
                                        <td class="todo" style="width: 100%;"></td>
                                    </tr>
                                </tbody>
                            </table>
                            <p class="pourcent"><?php echo $task_data['task_percent_done']; ?>%</p>
                        </td>
                    </tr>
                    <tr>
                        <th class="category">Chủ đề:</th>
                        <td class="category"><?php echo $task_data['category_name']; ?></td>
                        <th class="estimated-hours">Thời gian ước đoán:</th>
                        <td class="estimated-hours"><?php echo $task_data['task_estimated_time']; ?> giờ</td>
                    </tr>
                    <tr>
                        <th class="fixed-version">Giai đoạn:</th>
                        <td class="fixed-version"><?php echo $task_data['version_name']; ?></td>
                        <th class="spent-time">Thời gian:</th>
                        <td class="spent-time"><?php if($log_data != null){$total_time = 0; foreach($log_data as $row2){$total_time = $total_time + $row2['log_hour'];} echo $total_time . " giờ";}else{ echo "-";} ?></td>
                    </tr>
                </tbody>
            </table>

            <hr>
            <!--<div class="contextual">
            <a href="javascript:" class="icon icon-comment" data-method="post" data-remote="true" rel="nofollow">Trích dẫn</a>
            </div>-->

            <p><strong>Mô tả</strong></p>
            <div class="wiki">
                <p><?php echo $task_data['task_description']; ?></p>
            </div>            

        </div>

        <div style="clear: both;"></div>
        <div class="contextual">
            <?php foreach($assign_data as $row){
                if($row['assign_user_id'] == $_SESSION['user_pm']['user_id']){                
                 ?>
            <a href="<?php echo $url->createUrl("task/logtime",array("task_id"=>$task_data['task_id'])); ?>" class="icon icon-time-add">Cập nhật</a>                          
            <?php } } ?>          
            <?php if($_SESSION['project_pm']['project_admin_id'] == $_SESSION['user_pm']['user_id']){ ?>
                <a href="<?php echo $url->createUrl("task/update",array("task_id"=>$task_data['task_id'])); ?>" class="icon icon-edit">Sửa</a>
                <a href="javascript:" class="icon icon-del" rel="nofollow" onclick="delete_task(<?php echo $task_data['task_id']; ?>)">Xóa</a>
                <?php } ?>
        </div>

        <div style="clear: both;"></div>




        <h2>Thời gian</h2>

        <div id="tab-content-versions" class="tab-content">
            <table class="list versions">
                <thead>
                    <tr>                        
                        <th>Ngày</th>
                        <th>Thành viên</th>
                        <th>Công việc</th>
                        <th>Mô tả</th>                    
                        <th style="width:15%">Giờ</th>
                    </tr>
                </thead>
                <tbody>
                    <?php for($i=0;$i<count($log_data);$i++){?>
                        <tr class="version <?php if(($i%2) == 1){echo "even";}else{echo "odd";} ?> open" id="version_row_<?php echo $data[$i]['version_id']; ?>">
                            <td class="date"><?php echo date('d/m/Y',$log_data[$i]['log_date']); ?></td>
                            <td class="date"><a href="<?php echo $url->createUrl("user/detail",array("user_id"=>$log_data[$i]['user_id'])); ?>"><?php echo $log_data[$i]['fullname']; ?></a></td>                            
                            <td class="date"><?php echo $task_data['task_name'];?></td>                            
                            <td class="date"><?php echo $log_data[$i]['log_description'];?></td>                            
                            <td class="date"><?php echo $log_data[$i]['log_hour'];?></td>                            
                        </tr>
                        <?php } ?>                
                </tbody>
            </table>                        
        </div>


    </div>
</div>

<?php include "detail.js.php"; ?>